#!/usr/bin/env python
# -*- coding=utf-8 -*-

import re

# (?s) (?m)
test_str1 = '''\
abc
abc
'''
no_results = re.findall(r'^abc',test_str1)

s_results = re.findall(r'(?s)^abc',test_str1)

m_results = re.findall(r'(?m)^abc',test_str1)

print('###test1')
print('no_results is {no_results}\ns_results is {s_results}\nm_results is {m_results}'.format(
    **globals()))


# (?s) 将使得 .可以匹配\n
test_str1 = """abc
abc"""
s_results = re.search(r'(?s).*',test_str1).group()
no_results = re.search(r'.*',test_str1).group()
print('###test2')
print('no_results is {no_results}\ns_results is {s_results}'.format(
    **globals()))

## (?P<tag>) (?P=tag)
test_str2 = 'abc_otherthing_abc'

results =re.search(r'(?P<tag>abc)\w+(?P=tag)',test_str2)
print('###test3')
print(results.group())


## None results

test_str = 'abc'
results = re.search(r'\d+',test_str)

if results is None:
    print('No Results!')
else:
    pass